class SchGoods{
	constructor(){
		this.url = "http://localhost/dist/static/schdata.json";
		this.cont = document.querySelector(".container .schoolRead .childimg");
		this.load();
	}
	load(){
		ajax({
			url:this.url
		}).then((res)=>{
			this.res = JSON.parse(res);
			this.display();
		});
	}
	display(){
		var strschool = "";
	    strschool = `<div class="childimgbox">
					<a href="#"><img src="http://img1.zazhipu.com/bookpic/201912/2019121192926.jpg?imageMogr2/thumbnail/450x" /></a>
				</div>`;
	    for(var i=0;i<this.res.length;i++){
	        strschool += `<div class="childimgbox" index="${this.res[i].goodsId}">
	        			<a href="pages/details.html?id=${this.res[i].goodsId}" target="_blank">
						<img src="${this.res[i].img}" alt="" />
						<p>${this.res[i].name}</p>
						<div class="childMoney">
							<div class="left">${this.res[i].price}</div>
							<div class="right">${this.res[i].details}</div>
						</div>
						</a>
					</div>`;
	    }
		this.cont.innerHTML = strschool;
	}
}

new SchGoods();


//
//var imgs = document.querySelectorAll(".container .schoolRead .childimg img");
//console.log(imgs);
//var clientH = document.documentElement.clientHeight;
//
//lazyLoading(imgs);
//onscroll = function(imgs){
//	lazyLoading(imgs);
//}
//function lazyLoading(imgs){
//	var arr = Array.from(imgs);
//	var scrollT = document.documentElement.scrollTop;
//	for(var i=0;i<arr.length;i++){
//		if(arr[i].offsetTop-100 < clientH + scrollT){
//			arr[i].src = arr[i].getAttribute("data-src");
//			arr.splice(i,1);
//			i--;
//		}
//	}
//}